package org.jeecg.modules.wlhy.hybank.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.constant.CacheConstant;
import org.jeecg.modules.wlhy.hybank.entity.HyBank;
import org.jeecg.modules.wlhy.hybank.mapper.HyBankMapper;
import org.jeecg.modules.wlhy.hybank.service.IHyBankService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @Description: hy_bank
 * @Author: jeecg-boot
 * @Date:   2021-11-26
 * @Version: V1.0
 */
@Service
public class HyBankServiceImpl extends ServiceImpl<HyBankMapper, HyBank> implements IHyBankService {

    @Override
    @CacheEvict(cacheNames= CacheConstant.CACHE_HY_BANK, key="#entity.bankType")
    public boolean updateById(HyBank entity) {
        return baseMapper.updateById(entity)==1;
    }

    @Override
    @Cacheable(unless="#result == null", cacheNames= CacheConstant.CACHE_HY_BANK, key="#bankType")
    public HyBank getByBankType(String bankType) {
        return this.getOne(new QueryWrapper<HyBank>().eq("bank_type", bankType));
    }

    @Override
    public HyBank getByBankName2(String bankName2) {
        return this.getOne(new QueryWrapper<HyBank>().eq("bank_name2", bankName2));
    }

    @Override
    public HyBank getByBankName(String bankName) {
        return this.getOne(new QueryWrapper<HyBank>().eq("bank_name", bankName));
    }
}
